#include "Zone.h"

#ifndef NULL
#define NULL (0L)
#endif

Zone::Zone(void)
{
	m_ZoneID = 0;
	m_ZoneType = ZONE_PLAINS;
	m_NeighborNorth = NULL;
	m_NeighborSouth = NULL;
	m_NeighborEast = NULL;
	m_NeighborWest = NULL;
}


Zone::~Zone(void)
{
	m_ZoneID = 0;
	m_ZoneType = ZONE_PLAINS;
	m_NeighborNorth = NULL;
	m_NeighborSouth = NULL;
	m_NeighborEast = NULL;
	m_NeighborWest = NULL;
}

// Accessors
int Zone::GetZoneID(void)
{
	return m_ZoneID;
}

int Zone::GetZoneType(void)
{
	return m_ZoneType;
}

Zone* Zone::GetZoneNeighbor(int direction)
{
	switch( direction )
	{
	case NORTH:
		{
			return m_NeighborNorth;
		}
		break;
	case SOUTH:
		{
			return m_NeighborSouth;
		}
		break;
	case WEST:
		{
			return m_NeighborWest;
		}
		break;
	case EAST:
		{
			return m_NeighborEast;
		}
		break;
	default:
		{
			return NULL;
		}
		break;
	}
}

// Mutators
void Zone::SetZoneID(int id)
{
	m_ZoneID = id;
}

void Zone::SetZoneType(int type)
{
	m_ZoneType = type;
}

void Zone::SetNeighbor(Zone* zone, int direction)
{
	switch( direction )
	{
	case NORTH:
		{
			m_NeighborNorth = zone;
		}
		break;
	case SOUTH:
		{
			m_NeighborSouth = zone;
		}
		break;
	case WEST:
		{
			m_NeighborWest = zone;
		}
		break;
	case EAST:
		{
			m_NeighborEast = zone;
		}
		break;
	default:
		break;
	}
}

bool Zone::CheckNeighbor(int direction, int zoneType)
{
	switch( direction )
	{
	case NORTH:
		{
			if( m_NeighborNorth )
			{
				return m_NeighborNorth->GetZoneType() != zoneType;
			}
		}
		break;
	case SOUTH:
		{
			if( m_NeighborSouth )
			{
				return m_NeighborSouth->GetZoneType() != zoneType;
			}
		}
		break;
	case WEST:
		{
			if( m_NeighborWest )
			{
				return m_NeighborWest->GetZoneType() != zoneType;
			}
		}
		break;
	case EAST:
		{
			if( m_NeighborEast )
			{
				return m_NeighborEast->GetZoneType() != zoneType;
			}
		}
		break;
	default:
		{
			return false;
		}
		break;
	}

	return false;
}

int	Zone::GetZoneX(void)
{
	return m_ZonePositionX;
}

int	Zone::GetZoneY(void)
{
	return m_ZonePositionY;
}

void Zone::SetZoneX(int x)
{
	m_ZonePositionX = x;
}

void Zone::SetZoneY(int y)
{
	m_ZonePositionY = y;
}